<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>YouPlay</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="bootstrap.css" rel="stylesheet">
<script src="holaplayer.js"></script>
<style>
body {
padding-top: 60px;
}
</style>
<link href="bootstrap-responsive.css" rel="stylesheet">
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="#">YouPlay</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li><a href="index.php">Home</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="container">
<?php
$config = new stdClass();
$config->host = "localhost";
$config->username = "";
$config->password = "";
$config->database = "";
$db = mysqli_connect($config->host,$config->username,$config->password,$config->database);
if(!isset($_GET["id"])) {
?>
<table class="table">
<thead>
<tr>
<th>Play</th>
<th>Artist</th>
<th>Title</th>
</tr>
</thead>
<tbody>
<?php
$list = mysqli_query($db,"SELECT * FROM youplay");
while($entry = mysqli_fetch_assoc($list)) {
echo "<tr>";
echo "<td><a href='index.php?id=".$entry["id"]."'>Play</a></td>";
echo "<td>".htmlspecialchars($entry["artist"])."</td>";
echo "<td>".htmlspecialchars($entry["title"])."</td>";
echo "</tr>";
}
?>
</tbody>
</table>
<?php
}
else {
include("ytclass.php");
$ytclass = new YTDownloader();
$video = mysqli_fetch_assoc(mysqli_query($db,"SELECT * FROM youplay WHERE id='".mysqli_real_escape_string($db,$_GET["id"])."'"));
$vdata = $ytclass->getDownloadLinks($video["watchid"]);
$vlink = $vdata["dl"];
?>
<div class='page-header'>
<h1><?php echo htmlspecialchars($video["title"]) ?>
<small> <?php echo htmlspecialchars($video["artist"]) ?></small></h1>
</div>
<video class="video-js vjs-default-skin" controls id="player" cover="<?=$vdata["info"]["Thumbnail"]?>" title="<?=$vdata["info"]["Title"]?>" style="width:90%;margin-left:5%">
Your browser does not support the video tag.
</video>
<script>
hola_player({share:false,sources:[
<?php
for($i=0;$i<count($vlink);$i++) {
if(!strstr($vlink[$i]["type"],"(Audio Only)"))
echo "{src:'".$vlink[$i]["url"]."',label:'".$vlink[$i]["type"]."'},";
}
?>
]});
</script>
<? } ?>
</div>
</body>
</html>
